<script setup lang="ts">
import { useOrderCar } from "@/views/order/deliver/orderCar/utils/hook";
import Refresh from "@iconify-icons/ep/refresh";
import { PureTableBar } from "@/components/RePureTableBar";
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
import { ref } from "vue";
export interface FormProps {
  data: any;
}
const props = withDefaults(defineProps<FormProps>(), {
  data: 0
});
const {
  loading,
  columns,
  dataList,
  pagination,
  isShow,
  onSearch,
  handleSizeChange,
  handleCurrentChange,
  deviceDetection,
  handleDelete,
  handleCheck
} = useOrderCar(props.data);
</script>

<template>
  <PureTableBar
    :class="[isShow && !deviceDetection() ? '!w-[60vw]' : 'w-full']"
    style="transition: width 220ms cubic-bezier(0.4, 0, 0.2, 1)"
    title="发货单车辆列表"
    :columns="columns"
    @refresh="onSearch"
  >
    <template v-slot="{ size, dynamicColumns }">
      <pure-table
        ref="tableRef"
        align-whole="center"
        showOverflowTooltip
        table-layout="auto"
        :loading="loading"
        :size="size"
        adaptive
        :adaptiveConfig="{ offsetBottom: 308 }"
        :data="dataList"
        :columns="dynamicColumns"
        :pagination="pagination"
        :paginationSmall="size === 'small' ? true : false"
        :header-cell-style="{
          background: 'var(--el-fill-color-light)',
          color: 'var(--el-text-color-primary)'
        }"
        @page-size-change="handleSizeChange"
        @page-current-change="handleCurrentChange"
      >
        <template #operation="{ row }">
          <el-popconfirm
            v-if="row.entryStatus === 0"
            :title="`是否通过?`"
            @confirm="handleCheck(row.vehicleTimelineId, 1)"
          >
            <template #reference>
              <el-button class="reset-margin" link type="primary" :size="size">
                通过
              </el-button>
            </template>
          </el-popconfirm>
          <el-popconfirm
            v-if="row.vehicleInfo === 0"
            :title="`是否拒绝?`"
            @confirm="handleCheck(row.vehicleTimelineId, 2)"
          >
            <template #reference>
              <el-button class="reset-margin" link type="primary" :size="size">
                拒绝
              </el-button>
            </template>
          </el-popconfirm>
          <el-popconfirm :title="`是否确认删除?`" @confirm="handleDelete(row)">
            <template #reference>
              <el-button class="reset-margin" link type="primary" :size="size">
                删除
              </el-button>
            </template>
          </el-popconfirm>
        </template>
      </pure-table>
    </template>
  </PureTableBar>
</template>

<style scoped lang="scss"></style>
